package cn.tedu.eb_film.controller;

import cn.tedu.eb_film.ex.ServiceException;
import cn.tedu.eb_film.pojo.dto.SelectSeatDTO;
import cn.tedu.eb_film.pojo.vo.SelectSeatVO;
import cn.tedu.eb_film.service.SelectSeatService;
import cn.tedu.eb_film.utils.JsonResult;
import cn.tedu.eb_film.utils.ServiceCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.ws.Action;

/**
 * @author ライナー・ロンテ
 * @since 2023/4/19 17:30
 */
@RestController
@RequestMapping("selectSeat")
public class SelectSeatController {
    @Autowired
    public SelectSeatService selectSeatService;

    @PostMapping("load")
    public JsonResult<SelectSeatVO> load(@RequestBody SelectSeatDTO selectSeatDTO){
        if (selectSeatDTO.getUserId() == null) {
            throw new ServiceException(ServiceCode.ERROR_UNKNOWN,"你没登录,请登录");
        }
        SelectSeatVO selectSeatVO = selectSeatService.loadSeat(selectSeatDTO);
        return JsonResult.ok(selectSeatVO);
    }
}
